﻿using B.S.Warehouse.ErrorCord;
using B.S.Warehouse.Write.Api.Application.Command.GoodsCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Warehouse.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GoodsController : ControllerBase
    {
        private readonly IMediator mediator;

        public GoodsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 货品信息添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddGoods(AddGoodsCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 货品信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateGoods(UpdateGoodsCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 货品信息删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult<int>> DelGoods([FromQuery] DelGoodsCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
